<?php
error_reporting(E_ALL);
ob_implicit_flush();
ini_set('display_errors', '1');



/* var_dump($_POST); */
/* echo "<br />"; */

include_once "../config.php";
require_once "../util.php";

connect_db();

$email = mysql_real_escape_string($_POST['email']);
$passwd = mysql_real_escape_string($_POST['password']);
$categories = mysql_real_escape_string($_POST['categories']);
$tags = mysql_real_escape_string($_POST['tags']);
$poison_tags = mysql_real_escape_string($_POST['poison_tags']);
$victim_keywords = mysql_real_escape_string($_POST['victim_keywords']);
$enabled = (isset($_POST['enabled']) && $_POST['enabled'] == 'yeah') ? 1 : 0;

header ('Content-type: text/html; charset=utf-8');
$sql = sprintf("insert sina_user(email, passwd, categories, tags, poison_tags, victim_keywords, enabled)
values('%s', '%s', '%s', '%s', '%s', '%s', '%d') 
on duplicate key update
email = '%s', passwd = '%s', categories = '%s', tags = '%s', poison_tags = '%s', victim_keywords = '%s', enabled = %d",
               $email, $passwd, $categories, $tags, $poison_tags, $victim_keywords, $enabled,
               $email, $passwd, $categories, $tags, $poison_tags, $victim_keywords, $enabled);

//echo $sql;

$ret = mysql_query($sql);
if (!$ret) {
  echo "mysql($sql) failed: ". mysql_error() . "<br />";
  return;
}

echo mysql_affected_rows() . ' rows affected, 即将自动跳转到profile页面, Good luck hacking!' . "<br />";
echo sprintf('<META HTTP-EQUIV="refresh" CONTENT="3; URL=update_profile.php?email=%s">', $email);
return;
?>

